#ifndef _ABSTRACT_THREAD_H
#define _ABSTRACT_THREAD_H

#include <pthread.h>

class AbstractThread
{
public:
	AbstractThread(void);
	virtual ~AbstractThread(void);

	bool Start();
	bool Stop(bool waitQuit = true);
	bool IsRunning();
	void Join();
	void SetThreadName(const char* name);
	void Lock();
	void UnLock();

protected:
	void TestCancel();
	virtual void DoAction() = 0;
	virtual void CleanUp();

private:
	static void* thread(void* param); 
	static void cleanup(void* param);

private:
	pthread_t* m_thread;
	pthread_mutex_t* m_mutex;
	char* m_name;
};

#endif //_ABSTRACT_THREAD_H
